{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "f33871a5",
   "metadata": {
    "pycharm": {
     "name": "#%% md\n"
    }
   },
   "source": [
    "- 2022.9.6 week03\n",
    "- Python 课堂笔记\n",
    "- 记录人：欣欣\n",
    "---"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "5634dd90",
   "metadata": {
    "pycharm": {
     "name": "#%% md\n"
    }
   },
   "source": [
    "# 本周知识点：\n",
    ">  1. 回顾变量的概念\n",
    ">  2. 条件判断\n",
    ">  3. for循环和range方法\n",
    ">  4. random模块（伪随机数模块）"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "758b9e48",
   "metadata": {
    "pycharm": {
     "name": "#%% md\n"
    }
   },
   "source": [
    "## 1.回顾变量的概念"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "2134b356",
   "metadata": {
    "pycharm": {
     "is_executing": true,
     "name": "#%%\n"
    }
   },
   "outputs": [],
   "source": [
    "# 例子：\n",
    "网新_01_ID = \"2110130077\"\n",
    "网新_02_ID = \"2110130078\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "8d432afc",
   "metadata": {
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'2110130077'"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "网新_01_ID"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "d3c7a0ae",
   "metadata": {
    "pycharm": {
     "name": "#%% md\n"
    }
   },
   "source": [
    "## 2.条件判断"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "c0493dbb",
   "metadata": {
    "pycharm": {
     "name": "#%% md\n"
    }
   },
   "source": [
    "> 1. if else\n",
    "> 2. 课后练习：关于if条件判断练习"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "93b17da0",
   "metadata": {
    "pycharm": {
     "name": "#%% md\n"
    }
   },
   "source": [
    "# 3.关于模块，变量和if条件判断的课本案例1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "07250074",
   "metadata": {
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "50\n",
      "现在是秒/时间为偶数\n"
     ]
    }
   ],
   "source": [
    "import datetime\n",
    "# 本项目用到了时间模块\n",
    "# print(datetime.datetime.today().microsecond)\n",
    "\n",
    "# odds 是一个变量，后面可以直接使用它\n",
    "odds = [  1, 3,  5,  7,  9, 11,13,15,17,19,\n",
    "             21,23,25,27,29,31,33,35,37,39,\n",
    "             41,43,45,47,49,51,53,55,57,59]\n",
    "\n",
    "# right_this_minute 是一个变量，是随着当前时间分钟数不断变化的一个值\n",
    "right_this_minute = datetime.datetime.today().second\n",
    "\n",
    "if right_this_minute in odds:\n",
    "    print(right_this_minute)\n",
    "    print(\"现在是秒/时间为奇数\")\n",
    "else:\n",
    "    print(right_this_minute)\n",
    "    print(\"现在是秒/时间为偶数\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "7a7eec90",
   "metadata": {
    "pycharm": {
     "name": "#%% md\n"
    }
   },
   "source": [
    "- 判断当前是一周中的星期几，打印python课表\n",
    "\n",
    "- 实践：通过if判断 来实现课程表的打印\n",
    "\n",
    "- 课本P18"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "f3e2ca3b",
   "metadata": {
    "pycharm": {
     "name": "#%% md\n"
    }
   },
   "source": [
    "### 通过help(datetime)来搜索datetime的知识和相关使用要求"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "81cf0d32",
   "metadata": {
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "datetime.date(2022, 9, 6)"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import datetime\n",
    "datetime.date.today()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "8413213b",
   "metadata": {
    "pycharm": {
     "name": "#%% md\n"
    }
   },
   "source": [
    "### 看如上案例：datetime可以获取到年月日，但是无法得到周几。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "f52206ab",
   "metadata": {
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1"
      ]
     },
     "execution_count": 1,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import time\n",
    "time.localtime().tm_wday"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "70bd1b5f",
   "metadata": {
    "pycharm": {
     "name": "#%% md\n"
    }
   },
   "source": [
    "### 创建today变量(模块获取今天是星期几？)\n",
    "### 知识点：\n",
    "- 1.先创建变量，才能进行判断\n",
    "- 2.if语句 观察条件判断块的位置\n",
    "- 3.按照条件块的间隙，找到归属关系。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "id": "9e5c00cd",
   "metadata": {
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Work,work,work.\n"
     ]
    }
   ],
   "source": [
    "# 在这里，today为你创建的变量，\"=\"是判断\n",
    "\n",
    "today = \"Friday\"\n",
    "condition = \"good\"\n",
    "\n",
    "if today == \"Saturday\":\n",
    "    print(\"happy\")  # if条件判断块\n",
    "elif today == \"Sunday\":\n",
    "    if condition == \"Headache\":\n",
    "        print(\"Recover,then rest.\")\n",
    "    else:\n",
    "        print(\"Rest.\")\n",
    "else:\n",
    "    print(\"Work,work,work.\")\n",
    "    "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "c6d2faec",
   "metadata": {
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [],
   "source": [
    "- 判断当前是一周中的星期几，若是周二，看下现在几点了，打印课程表。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "11dd3fc6",
   "metadata": {
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [],
   "source": [
    "# wday = 0,1,2,3,4,5,6  分别指周一到周日\n",
    "import time\n",
    "\n",
    "wday  = time.localtime().tm_wday"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "fb43fcaf",
   "metadata": {
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [],
   "source": [
    "time_hour = time.localtime ().tm_hour"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "0bf7286e",
   "metadata": {
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [],
   "source": [
    "time_min = time.localtime().tm_min"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "de3a7858",
   "metadata": {
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "今天没有python课\n"
     ]
    }
   ],
   "source": [
    "if wday != 1: # 判断是否是周二\n",
    "    print(\"今天没有python课\")\n",
    "elif time_hour  == 12 and time_min > 50:\n",
    "    print(\"正在上python课，刚上课\")\n",
    "elif time_hour  ==15:\n",
    "    print(\"正在上Python课，坚持一下，快下课了！\")\n",
    "elif time_hour == 16 and time_min<50:\n",
    "    print(\"正在上Python课，最后一节课了，下课啦\")\n",
    "else:\n",
    "    print(\"今天有python课，上课时间是下午12：50-16：50\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "eb1aaa13",
   "metadata": {
    "pycharm": {
     "name": "#%% md\n"
    }
   },
   "source": [
    "# 4. for循环和range方法"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "d077c82e",
   "metadata": {},
   "source": [
    "### item循环遍历"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "94076a0a",
   "metadata": {},
   "source": [
    "### 使用格式;for item in range():  print(item)  # item是形式"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "2c91dc0a",
   "metadata": {
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1\n",
      "2\n",
      "3\n"
     ]
    }
   ],
   "source": [
    "for item in [1,2,3]:\n",
    "    print(item)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "39979f95",
   "metadata": {
    "pycharm": {
     "name": "#%% md\n"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "211013001\n",
      "211013002\n",
      "211013003\n"
     ]
    }
   ],
   "source": [
    "# 自动生成学号\n",
    "for item in [1,2,3]:\n",
    "    print(item+211013000)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "c39a6823",
   "metadata": {
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0\n",
      "1\n",
      "2\n",
      "3\n",
      "4\n"
     ]
    }
   ],
   "source": [
    "#  range()自动生成想要的数值，可以控制for循环的次数，一个值，就是从0开始几个数\n",
    "for num in range(5): # range从0开始。（）内的数字是从0开始数几个数\n",
    "    print(num)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "6fe5ad26",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "2\n",
      "3\n",
      "4\n"
     ]
    }
   ],
   "source": [
    "# range()自动生成想要的数值，可以控制for循环的次数，两个值，从小数（2）开始，大数-小数的个数（5-2）\n",
    "for num in range(2,5): # 是区间2-5之间的数字\n",
    "    print(num)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "e773fed6",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0\n",
      "3\n",
      "6\n",
      "9\n"
     ]
    }
   ],
   "source": [
    "# 三个值，第三个值决定step步长\n",
    "for num in range(0,10,3): #取0-10之间的数字，且是3的倍数，第三个值决定了倍数\n",
    "    print(num)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "f6db8790",
   "metadata": {},
   "source": [
    "### for循环遍历案例 ： 某学校新闻网站数据URL队列获取"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "57a4e58f",
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "https://www.nfu.edu.cn/ztb/index0.htm\n",
      "https://www.nfu.edu.cn/ztb/index1.htm\n",
      "https://www.nfu.edu.cn/ztb/index2.htm\n",
      "https://www.nfu.edu.cn/ztb/index3.htm\n",
      "https://www.nfu.edu.cn/ztb/index4.htm\n",
      "https://www.nfu.edu.cn/ztb/index5.htm\n",
      "https://www.nfu.edu.cn/ztb/index6.htm\n",
      "https://www.nfu.edu.cn/ztb/index7.htm\n",
      "https://www.nfu.edu.cn/ztb/index8.htm\n",
      "https://www.nfu.edu.cn/ztb/index9.htm\n",
      "https://www.nfu.edu.cn/ztb/index10.htm\n",
      "https://www.nfu.edu.cn/ztb/index11.htm\n",
      "https://www.nfu.edu.cn/ztb/index12.htm\n",
      "https://www.nfu.edu.cn/ztb/index13.htm\n",
      "https://www.nfu.edu.cn/ztb/index14.htm\n",
      "https://www.nfu.edu.cn/ztb/index15.htm\n",
      "https://www.nfu.edu.cn/ztb/index16.htm\n",
      "https://www.nfu.edu.cn/ztb/index17.htm\n",
      "https://www.nfu.edu.cn/ztb/index18.htm\n",
      "https://www.nfu.edu.cn/ztb/index19.htm\n",
      "https://www.nfu.edu.cn/ztb/index20.htm\n",
      "https://www.nfu.edu.cn/ztb/index21.htm\n",
      "https://www.nfu.edu.cn/ztb/index22.htm\n",
      "https://www.nfu.edu.cn/ztb/index23.htm\n",
      "https://www.nfu.edu.cn/ztb/index24.htm\n",
      "https://www.nfu.edu.cn/ztb/index25.htm\n",
      "https://www.nfu.edu.cn/ztb/index26.htm\n"
     ]
    }
   ],
   "source": [
    "# 中大南方-招投标- https://www.nfu.edu.cn/ztb/index.htm\n",
    "\n",
    "中大南方_招投标 = \"https://www.nfu.edu.cn/ztb/index.htm\"\n",
    "for page in range(27):\n",
    "    print(\"https://www.nfu.edu.cn/ztb/index\" + str(page) + \".htm\" )"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "1c8c5d86",
   "metadata": {},
   "source": [
    "# 5.Random模块"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "72ea44fc",
   "metadata": {},
   "outputs": [],
   "source": [
    "import random"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "fe282c13",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0.5026121021338239"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# random.random方法: 取（0，1）\n",
    "random.random()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "a88cf9d3",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "32"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# random.randint(a,b),随机生成 a-b 之间的一个数值\n",
    "import random\n",
    "random.randint(1,50)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "78f45ec1",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1\n",
      "1\n",
      "4\n",
      "4\n",
      "3\n"
     ]
    }
   ],
   "source": [
    "for i in range(5):\n",
    "    print(random.randint(1,6))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "0f2857ad",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'温欣欣'"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import random\n",
    "random.choice([\"温欣欣\",\"刘紫涵\",\"钟铃\",\"雷雨晴\"])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "40a5e4b3",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 课本P35实践"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "1228487c",
   "metadata": {},
   "outputs": [],
   "source": [
    "# help(random)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "70de5e65",
   "metadata": {},
   "outputs": [],
   "source": [
    "import time"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "34795875",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "hello world\n"
     ]
    }
   ],
   "source": [
    "time.sleep(3)\n",
    "print(\"hello world\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "234c9a84",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "51"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "random.randint(10,70)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "id": "6fac92e3",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "2\n",
      "现在秒/时间为偶数\n",
      "3\n",
      "现在是秒/时间为奇数\n",
      "6\n",
      "现在秒/时间为偶数\n",
      "7\n",
      "现在是秒/时间为奇数\n",
      "12\n",
      "现在秒/时间为偶数\n"
     ]
    }
   ],
   "source": [
    "import datetime\n",
    "import time\n",
    "import random\n",
    "\n",
    "odds = [  1, 3,  5,  7,  9, 11,13,15,17,19,\n",
    "             21,23,25,27,29,31,33,35,37,39,\n",
    "             41,43,45,47,49,51,53,55,57,59]\n",
    "for i in range(5):\n",
    "    right_this_minute = datetime.datetime.today().second\n",
    "    if right_this_minute in odds:\n",
    "        print(right_this_minute)\n",
    "        print(\"现在是秒/时间为奇数\")\n",
    "    else:\n",
    "        print(right_this_minute)\n",
    "        print(\"现在秒/时间为偶数\")\n",
    "    time.sleep(random.randint(1,6))\n",
    "    \n",
    "# 爬虫，爬数据，每隔5秒抓一次数据\n",
    "# 反爬虫，"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "c9425d95",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 课本P43实践"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "id": "600c120d",
   "metadata": {
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "99 bottles 在啤酒墙上\n",
      "99 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "98 bottles 在啤酒墙上\n",
      "\n",
      "98 bottles 在啤酒墙上\n",
      "98 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "97 bottles 在啤酒墙上\n",
      "\n",
      "97 bottles 在啤酒墙上\n",
      "97 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "96 bottles 在啤酒墙上\n",
      "\n",
      "96 bottles 在啤酒墙上\n",
      "96 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "95 bottles 在啤酒墙上\n",
      "\n",
      "95 bottles 在啤酒墙上\n",
      "95 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "94 bottles 在啤酒墙上\n",
      "\n",
      "94 bottles 在啤酒墙上\n",
      "94 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "93 bottles 在啤酒墙上\n",
      "\n",
      "93 bottles 在啤酒墙上\n",
      "93 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "92 bottles 在啤酒墙上\n",
      "\n",
      "92 bottles 在啤酒墙上\n",
      "92 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "91 bottles 在啤酒墙上\n",
      "\n",
      "91 bottles 在啤酒墙上\n",
      "91 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "90 bottles 在啤酒墙上\n",
      "\n",
      "90 bottles 在啤酒墙上\n",
      "90 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "89 bottles 在啤酒墙上\n",
      "\n",
      "89 bottles 在啤酒墙上\n",
      "89 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "88 bottles 在啤酒墙上\n",
      "\n",
      "88 bottles 在啤酒墙上\n",
      "88 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "87 bottles 在啤酒墙上\n",
      "\n",
      "87 bottles 在啤酒墙上\n",
      "87 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "86 bottles 在啤酒墙上\n",
      "\n",
      "86 bottles 在啤酒墙上\n",
      "86 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "85 bottles 在啤酒墙上\n",
      "\n",
      "85 bottles 在啤酒墙上\n",
      "85 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "84 bottles 在啤酒墙上\n",
      "\n",
      "84 bottles 在啤酒墙上\n",
      "84 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "83 bottles 在啤酒墙上\n",
      "\n",
      "83 bottles 在啤酒墙上\n",
      "83 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "82 bottles 在啤酒墙上\n",
      "\n",
      "82 bottles 在啤酒墙上\n",
      "82 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "81 bottles 在啤酒墙上\n",
      "\n",
      "81 bottles 在啤酒墙上\n",
      "81 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "80 bottles 在啤酒墙上\n",
      "\n",
      "80 bottles 在啤酒墙上\n",
      "80 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "79 bottles 在啤酒墙上\n",
      "\n",
      "79 bottles 在啤酒墙上\n",
      "79 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "78 bottles 在啤酒墙上\n",
      "\n",
      "78 bottles 在啤酒墙上\n",
      "78 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "77 bottles 在啤酒墙上\n",
      "\n",
      "77 bottles 在啤酒墙上\n",
      "77 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "76 bottles 在啤酒墙上\n",
      "\n",
      "76 bottles 在啤酒墙上\n",
      "76 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "75 bottles 在啤酒墙上\n",
      "\n",
      "75 bottles 在啤酒墙上\n",
      "75 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "74 bottles 在啤酒墙上\n",
      "\n",
      "74 bottles 在啤酒墙上\n",
      "74 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "73 bottles 在啤酒墙上\n",
      "\n",
      "73 bottles 在啤酒墙上\n",
      "73 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "72 bottles 在啤酒墙上\n",
      "\n",
      "72 bottles 在啤酒墙上\n",
      "72 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "71 bottles 在啤酒墙上\n",
      "\n",
      "71 bottles 在啤酒墙上\n",
      "71 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "70 bottles 在啤酒墙上\n",
      "\n",
      "70 bottles 在啤酒墙上\n",
      "70 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "69 bottles 在啤酒墙上\n",
      "\n",
      "69 bottles 在啤酒墙上\n",
      "69 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "68 bottles 在啤酒墙上\n",
      "\n",
      "68 bottles 在啤酒墙上\n",
      "68 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "67 bottles 在啤酒墙上\n",
      "\n",
      "67 bottles 在啤酒墙上\n",
      "67 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "66 bottles 在啤酒墙上\n",
      "\n",
      "66 bottles 在啤酒墙上\n",
      "66 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "65 bottles 在啤酒墙上\n",
      "\n",
      "65 bottles 在啤酒墙上\n",
      "65 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "64 bottles 在啤酒墙上\n",
      "\n",
      "64 bottles 在啤酒墙上\n",
      "64 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "63 bottles 在啤酒墙上\n",
      "\n",
      "63 bottles 在啤酒墙上\n",
      "63 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "62 bottles 在啤酒墙上\n",
      "\n",
      "62 bottles 在啤酒墙上\n",
      "62 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "61 bottles 在啤酒墙上\n",
      "\n",
      "61 bottles 在啤酒墙上\n",
      "61 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "60 bottles 在啤酒墙上\n",
      "\n",
      "60 bottles 在啤酒墙上\n",
      "60 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "59 bottles 在啤酒墙上\n",
      "\n",
      "59 bottles 在啤酒墙上\n",
      "59 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "58 bottles 在啤酒墙上\n",
      "\n",
      "58 bottles 在啤酒墙上\n",
      "58 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "57 bottles 在啤酒墙上\n",
      "\n",
      "57 bottles 在啤酒墙上\n",
      "57 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "56 bottles 在啤酒墙上\n",
      "\n",
      "56 bottles 在啤酒墙上\n",
      "56 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "55 bottles 在啤酒墙上\n",
      "\n",
      "55 bottles 在啤酒墙上\n",
      "55 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "54 bottles 在啤酒墙上\n",
      "\n",
      "54 bottles 在啤酒墙上\n",
      "54 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "53 bottles 在啤酒墙上\n",
      "\n",
      "53 bottles 在啤酒墙上\n",
      "53 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "52 bottles 在啤酒墙上\n",
      "\n",
      "52 bottles 在啤酒墙上\n",
      "52 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "51 bottles 在啤酒墙上\n",
      "\n",
      "51 bottles 在啤酒墙上\n",
      "51 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "50 bottles 在啤酒墙上\n",
      "\n",
      "50 bottles 在啤酒墙上\n",
      "50 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "49 bottles 在啤酒墙上\n",
      "\n",
      "49 bottles 在啤酒墙上\n",
      "49 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "48 bottles 在啤酒墙上\n",
      "\n",
      "48 bottles 在啤酒墙上\n",
      "48 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "47 bottles 在啤酒墙上\n",
      "\n",
      "47 bottles 在啤酒墙上\n",
      "47 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "46 bottles 在啤酒墙上\n",
      "\n",
      "46 bottles 在啤酒墙上\n",
      "46 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "45 bottles 在啤酒墙上\n",
      "\n",
      "45 bottles 在啤酒墙上\n",
      "45 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "44 bottles 在啤酒墙上\n",
      "\n",
      "44 bottles 在啤酒墙上\n",
      "44 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "43 bottles 在啤酒墙上\n",
      "\n",
      "43 bottles 在啤酒墙上\n",
      "43 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "42 bottles 在啤酒墙上\n",
      "\n",
      "42 bottles 在啤酒墙上\n",
      "42 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "41 bottles 在啤酒墙上\n",
      "\n",
      "41 bottles 在啤酒墙上\n",
      "41 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "40 bottles 在啤酒墙上\n",
      "\n",
      "40 bottles 在啤酒墙上\n",
      "40 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "39 bottles 在啤酒墙上\n",
      "\n",
      "39 bottles 在啤酒墙上\n",
      "39 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "38 bottles 在啤酒墙上\n",
      "\n",
      "38 bottles 在啤酒墙上\n",
      "38 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "37 bottles 在啤酒墙上\n",
      "\n",
      "37 bottles 在啤酒墙上\n",
      "37 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "36 bottles 在啤酒墙上\n",
      "\n",
      "36 bottles 在啤酒墙上\n",
      "36 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "35 bottles 在啤酒墙上\n",
      "\n",
      "35 bottles 在啤酒墙上\n",
      "35 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "34 bottles 在啤酒墙上\n",
      "\n",
      "34 bottles 在啤酒墙上\n",
      "34 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "33 bottles 在啤酒墙上\n",
      "\n",
      "33 bottles 在啤酒墙上\n",
      "33 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "32 bottles 在啤酒墙上\n",
      "\n",
      "32 bottles 在啤酒墙上\n",
      "32 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "31 bottles 在啤酒墙上\n",
      "\n",
      "31 bottles 在啤酒墙上\n",
      "31 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "30 bottles 在啤酒墙上\n",
      "\n",
      "30 bottles 在啤酒墙上\n",
      "30 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "29 bottles 在啤酒墙上\n",
      "\n",
      "29 bottles 在啤酒墙上\n",
      "29 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "28 bottles 在啤酒墙上\n",
      "\n",
      "28 bottles 在啤酒墙上\n",
      "28 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "27 bottles 在啤酒墙上\n",
      "\n",
      "27 bottles 在啤酒墙上\n",
      "27 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "26 bottles 在啤酒墙上\n",
      "\n",
      "26 bottles 在啤酒墙上\n",
      "26 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "25 bottles 在啤酒墙上\n",
      "\n",
      "25 bottles 在啤酒墙上\n",
      "25 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "24 bottles 在啤酒墙上\n",
      "\n",
      "24 bottles 在啤酒墙上\n",
      "24 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "23 bottles 在啤酒墙上\n",
      "\n",
      "23 bottles 在啤酒墙上\n",
      "23 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "22 bottles 在啤酒墙上\n",
      "\n",
      "22 bottles 在啤酒墙上\n",
      "22 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "21 bottles 在啤酒墙上\n",
      "\n",
      "21 bottles 在啤酒墙上\n",
      "21 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "20 bottles 在啤酒墙上\n",
      "\n",
      "20 bottles 在啤酒墙上\n",
      "20 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "19 bottles 在啤酒墙上\n",
      "\n",
      "19 bottles 在啤酒墙上\n",
      "19 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "18 bottles 在啤酒墙上\n",
      "\n",
      "18 bottles 在啤酒墙上\n",
      "18 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "17 bottles 在啤酒墙上\n",
      "\n",
      "17 bottles 在啤酒墙上\n",
      "17 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "16 bottles 在啤酒墙上\n",
      "\n",
      "16 bottles 在啤酒墙上\n",
      "16 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "15 bottles 在啤酒墙上\n",
      "\n",
      "15 bottles 在啤酒墙上\n",
      "15 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "14 bottles 在啤酒墙上\n",
      "\n",
      "14 bottles 在啤酒墙上\n",
      "14 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "13 bottles 在啤酒墙上\n",
      "\n",
      "13 bottles 在啤酒墙上\n",
      "13 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "12 bottles 在啤酒墙上\n",
      "\n",
      "12 bottles 在啤酒墙上\n",
      "12 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "11 bottles 在啤酒墙上\n",
      "\n",
      "11 bottles 在啤酒墙上\n",
      "11 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "10 bottles 在啤酒墙上\n",
      "\n",
      "10 bottles 在啤酒墙上\n",
      "10 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "9 bottles 在啤酒墙上\n",
      "\n",
      "9 bottles 在啤酒墙上\n",
      "9 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "8 bottles 在啤酒墙上\n",
      "\n",
      "8 bottles 在啤酒墙上\n",
      "8 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "7 bottles 在啤酒墙上\n",
      "\n",
      "7 bottles 在啤酒墙上\n",
      "7 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "6 bottles 在啤酒墙上\n",
      "\n",
      "6 bottles 在啤酒墙上\n",
      "6 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "5 bottles 在啤酒墙上\n",
      "\n",
      "5 bottles 在啤酒墙上\n",
      "5 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "4 bottles 在啤酒墙上\n",
      "\n",
      "4 bottles 在啤酒墙上\n",
      "4 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "3 bottles 在啤酒墙上\n",
      "\n",
      "3 bottles 在啤酒墙上\n",
      "3 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "2 bottles 在啤酒墙上\n",
      "\n",
      "2 bottles 在啤酒墙上\n",
      "2 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "1 bottle 在啤酒墙上\n",
      "\n",
      "1 bottle 在啤酒墙上\n",
      "1 bottle 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "没有更多的啤酒在啤酒墙上了，这瓶不给你，要展示的\n",
      "\n"
     ]
    }
   ],
   "source": [
    "word = \"bottles\"\n",
    "\n",
    "for beer_num in range(99,0,-1):\n",
    "    print(beer_num, word, \"在啤酒墙上\")\n",
    "    print(beer_num, word, \"啤酒\")\n",
    "    print(\"拿一瓶\")\n",
    "    print(\"传递它\")\n",
    "    if beer_num == 1:\n",
    "        print(\"没有更多的啤酒在啤酒墙上了，这瓶不给你，要展示的\")\n",
    "    else:\n",
    "        new_num = beer_num - 1\n",
    "        if new_num == 1:\n",
    "            word = \"bottle\"\n",
    "        print(new_num, word, \"在啤酒墙上\")\n",
    "    print()   "
   ]
  },
  {
   "cell_type": "markdown",
   "id": "db79a5c9",
   "metadata": {
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "source": [
    "# 总结：\n",
    "- 回顾变量\n",
    "- 条件判断\n",
    "- for循环和range方法\n",
    "- random模块 伪随机数模板"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.12"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
